home *** CD-ROM | disk | FTP | other *** search
- Path: news.cencom.net!ns!tanp
- From: tanp@ns (Bill Wendling)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with program
- Date: 19 Jan 1996 04:34:38 GMT
- Organization: Cen-Com Internet
- Message-ID: <4dn70u$43o@news.cencom.net>
- References: <4dkr5u$ro7@hasle.sn.no>
- NNTP-Posting-Host: ns.cencom.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Rune Elvemo inexplicably wrote:
-
- } /* Loadfile.c - loads a txt file, and shows it
- } **
- } **
- } */
-
- } #include <stdio.h>
-
- } struct Text
- } {
- } char *str;
- } struct Text *next;
- } }
- ^^ You need a semi-colon after this struct def!!!!!!!
-
- } enum BOOL { TRUE, FALSE };
-
- } /* prototype */
- } void PText(struct Text *);
-
-
- } main(int argc, char *argv[])
- } {
- } BOOL done = FALSE;
- } FILE *txtfile;
- } struct Text *first, *tst;
-
- } if (argc >1)
- } {
- } if (txtfile = fopen(argv[1], "r"))
- } {
- } if(first = calloc(1, sizeof(struct Text)))
- } {
- } tst = first;
- } if (fgetc(txtfile) != -1)
- } {
- } while (!done)
- } {
- } if (tst->str = calloc(256, sizeof(char)))
- } {
- } do
- } {
- } *tst->str = fgetc(txtfile);
- } tst->str++;
- } *tst->str = 0;
- } /* check if the last char was LineFeed or EOF */
-
- } } while ((*(tst->str - 1) != -1) &&
- } (*(tst->str) != 10));
- }
- } if (*tst->str == -1)
- } done = TRUE;
- } else
- } {
- } if (tst->next = calloc(1,
- } sizeof(struct Text)))
- } {
- } tst = tst->next;
-
- } }
- } else
- } {
- } done = TRUE;
- } printf("\n**!!Not enough
- } memory!!**\n");
- } }
- } }
- } }
- } }
- } tst->next = calloc(1, sizeof(struct Text));
- }
- }
- } PText(first);
- } }
- } }
- } else
- } printf("\n**!!Not enough memory!!**\n");
- } }
- } }
- } }
- }
- } /* Print the text that we have got */
- } void PText(struct Text *txt)
- } {
- } BOOL done = FALSE;
- } struct Text *jump;
-
- } jump = txt;
-
- } while(!done)
- } {
- } printf("%s", jump->str);
- }
- } while (*txt->next != 0)
- } {
- } jump = jump->next;
- }
- } printf("%s\n", jump);
- } }
- } }
- } }
- } Rune Elvemo
- } elvemo@oslonett.no
-
-
- --
- Bill Wendling | "Pinky, are you thinking what I'm thinking?"
- tanp@ns.cencom.net | "I think so, Brain, but burlap chafes me so."
- "Boom Shanka" | Finger me for my Geek Code...NOW!
-